FROM golang:1.14-alpine as builder

WORKDIR /go/src
COPY . .
RUN ls
ENV GO15VENDOREXPERIMENT=1
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags '-w' -o gin main.go

FROM alpine:3.2
COPY .alpine_repository /etc/apk/repositories
RUN apk add --update ca-certificates && \
    rm -rf /var/cache/apk/* /tmp/*

WORKDIR /
EXPOSE 80
COPY --from=0 /go/src/ .
ENTRYPOINT [ "/gin" ]